/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK 1.6+
 * <p>
 * 版权所有(C)：江苏欧索软件有限公司
 * <p>
 * 公司名称：江苏欧索软件有限公司
 * <p>
 * 公司地址：中国苏州科技城青山路1号
 * <p>
 * 网址: http://www.oceansoft.com.cn
 * <p>
 * 版本: 苏州公安统一用户管理平台1.0
 * <p>
 * 作者: 孙炯
 * <p>
 * 文件名:OperSysMgrController.java
 * <p>
 * 类产生时间: 2012-6-13 下午4:58:12
 * <p>
 * 负责人: 孙炯
 * 所在组 : 苏州公安统一用户管理平台
 * <p>
 * 所在部门: 电信/国土——技术二部
 * <p>
 * <p>
 */
package com.oceansoft.core.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.hui.platform.system.Constants;
import com.hui.platform.system.utility.DatetimeUtil;
import com.hui.platform.system.utility.StringUtil;
import com.oceansoft.core.common.util.Pagination;
import com.oceansoft.core.domain.SysOperLog;
import com.oceansoft.core.service.ISysOperMgrService;

@Controller
@RequestMapping("/oper")
public class OperSysMgrController {
	@Autowired
	private ISysOperMgrService sysOperMgrService;
	@RequestMapping("/query/{pageIndex}")
	public String query(ModelMap model, @PathVariable("pageIndex") int pageIndex, HttpServletRequest request) {
		String nowDate=DatetimeUtil.getCurrentDateAsString("yyyy-MM-dd");
		model.addAttribute("nowDate",nowDate);
		return "syslog/oper_list";
	}

	@RequestMapping("/log/{logId}")
	public String viewOperLogDetail(@PathVariable("logId") String logId, ModelMap model) {
		SysOperLog log = sysOperMgrService.findOperInfoById(logId);
		model.addAttribute("log", log);
		return "syslog/snap_view";
	}
	
	
	@RequestMapping("/query/list.json")
	public ModelAndView list(ModelMap model, HttpServletRequest request) {
		ModelAndView modelAndView = new ModelAndView(Constants.RESPONSE_VIEW);
		String pageIndex = request.getParameter("page");
		if(StringUtil.isNull(pageIndex))
		{
			pageIndex = "1";
		}
		String userid = request.getParameter("userid");
		String uname = request.getParameter("uname");
		String snapdata = request.getParameter("snapdata");
		String module = request.getParameter("module");
		String opertime1 = request.getParameter("opertime1");
		String opertime2 = request.getParameter("opertime2");
		Pagination<SysOperLog> page = sysOperMgrService.findOperInfoByConditions(userid, uname, module, snapdata,
				opertime1, opertime2,  Integer.parseInt(pageIndex));
		modelAndView.addObject("rows",page.getList());
		modelAndView.addObject("total",page.getTotalRows());
		return modelAndView;
	}
}
